﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Workflow.Common.Dao;
using Workflow.IDAO;
using Workflow.Model;
using NHibernate.Linq;

namespace Workflow.DAO
{
	public class TIdleDateDao : RepositoryBase<TIdleDate>, ITIdleDateDao
	{
		public IList<TIdleDate> GetTIdleDatesByPage(out long count, int pageIndex, int pageSize)
		{
			var result = Session.Query<TIdleDate>();

			
			count = result.LongCount();

			result = result.OrderByDescending(x => x.IdleDate);

			return result.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList<TIdleDate>();

		}


		public IList<TIdleDate> GetTIdleDatesByDate(DateTime idleDate)
		{
			var result = Session.Query<TIdleDate>();

			result = result.Where(x => x.IdleDate == idleDate);

			return result.ToList<TIdleDate>();
		}
	}
}
